package cn.sofwin.day0107.homework;

import javax.swing.plaf.IconUIResource;
import java.util.Scanner;

/**
 * 输入年份和月份，得到该月的天数。
 */
public class GetDay {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("请输入年：");
        double year = sc.nextDouble();
        System.out.print("请输入月：");
        int month = sc.nextInt();
        int days = 0;
        switch (month){
            case 1: case 3: case 5: case 7: case 8: case 10: case 12:
                days = 31;break;
            case 4: case 6: case 9: case 11:
                days = 30;break;
            case 2:
                days = 28;break;
            default:
                System.out.println("请检查输入是否有误");
                main(null);
        }
        if(((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) && (month == 2)){
            days++;
        }
        System.out.println("该月共有" + days + "天");
    }
}
